package com.datas.db.hibernatebeans;

import com.datas.utils.hibernatebasebean.BaseHibernateEntity;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.Date;

/**
 * Created by jige0727 on 2016/12/23.
 * 用户
 */
@Getter
@Setter
@Entity
public class UmsUser extends BaseHibernateEntity {
    private String username;
    private String password;
    //
    private Integer sex = 1; //1男 2女
    private String real_name; //姓名
    private String nick_name; //昵称
    //
    private String mobilephone;
    private String email;
    private String tel;
    //
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date ruzhi_time; //入职时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date lizhizhi_time; //离职时间

    private String ctct; //(联系人)、
    private String ctctTel; //(联系人电话)、

    @Column(nullable = false, unique = true)
    public String getUsername() {
        return username;
    }

    @Column(nullable = false)
    public String getPassword() {
        return password;
    }

    @Column(nullable = false)
    public String getReal_name() {
        return real_name;
    }

    @Transient
    public static String encodePass(String passRaw) {
        return DigestUtils.md5Hex(passRaw).toLowerCase();
    }

}
